﻿using System;
using StockModel;

namespace StockAnalyst2.Plugins.Visualization.Historical
{
	internal class DetailViewerRowVM
	{
		#region Attributes

		private readonly Operation _operation;
		private readonly decimal _accumulatedResult;
		private readonly decimal _totalAmountRequired;

		#endregion

		#region Properties

		public DateTime OpeningDate
		{
			get
			{
				return _operation.OpeningDate;
			}
		}

		public DateTime ClosingDate
		{
			get
			{
				return _operation.ClosingDate;
			}
		}

		public TimeSpan Duration
		{
			get
			{
				return _operation.ClosingDate - _operation.OpeningDate;
			}
		}

		public decimal BuyPrice
		{
			get
			{
				return _operation.BuyPrice;
			}
		}

		public decimal SellPrice
		{
			get
			{
				return _operation.SellPrice;
			}
		}

		public decimal GrossResult
		{
			get
			{
				return Math.Round(_operation.GrossResult, 2);
			}
		}

		public decimal Result
		{
			get
			{
				return Math.Round(_operation.Result, 2);
			}
		}

		public decimal ResultPercentage
		{
			get
			{
				return Math.Round(_operation.ResultPercentage, 2);
			}
		}

		public decimal ResultPercentageWithoutFees
		{
			get
			{
				return Math.Round(_operation.ResultPercentageWithoutFees, 2);
			}
		}

		public bool IsWinner
		{
			get
			{
				return _operation.IsWinner;
			}
		}

		public bool IsLongOperation
		{
			get
			{
				return _operation.IsLongOperation;
			}
		}

		public int Volume
		{
			get
			{
				return _operation.Volume;
			}
		}

		public decimal PartialAmountRequired
		{
			get
			{
                return Math.Round(_operation.AmountRequired, 2);
			}
		}

		public decimal TotalAmountRequired
		{
			get
			{
				return Math.Round(_totalAmountRequired, 2);
			}
		}

		public decimal Fee
		{
			get
			{
				return Math.Round(_operation.Fee, 2);
			}
		}

		public decimal AccummulatedResult
		{
			get
			{
				return  Math.Round(_accumulatedResult,2);
			}
		}

		
		#endregion

		#region Public Methods

		public DetailViewerRowVM(Operation operation, decimal accumulatedResult, decimal totalAmountRequired)
		{
			_operation = operation;
			_accumulatedResult = accumulatedResult;
			_totalAmountRequired = totalAmountRequired;
		}

		#endregion
	}
}
